home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
program
/
322
/
patch
/
configur
< prev
next >
Wrap
Text File
|
1988-10-20
|
17KB
|
677 lines
#! /bin/sh
#
# If these # comments don't work, trim them. Don't worry about any other
# shell scripts, Configure will trim # comments from them for you.
#
# Note: if you are running ksh, be sure to say "sh Configure".
#
# (If you are trying to port this package to a machine without sh, I would
# suggest you cut out the prototypical config.h from the end of Configure
# and edit it to reflect your system. Some packages may include samples
# of config.h for certain machines, so you might look for one of those.)
#
# $Header: Configure,v 2.0 86/09/17 15:32:58 lwall Exp $
#
# $Log: Configure,v $
# Revision 2.0 86/09/17 15:32:58 lwall
# Baseline for netwide release.
#
#
# Yes, you may rip this off to use in other distribution packages.
#
# (Note: this Configure script was generated automatically. Rather than
# working with this copy of Configure, you may wish to get metaconfig.)
define='define'
undef='/*undef'
d_eunice=''
eunicefix=''
loclist=''
expr=''
sed=''
echo=''
cat=''
rm=''
mv=''
cp=''
tail=''
tr=''
mkdir=''
sort=''
uniq=''
grep=''
trylist=''
test=''
inews=''
egrep=''
more=''
pg=''
Mcc=''
vi=''
mailx=''
Log=''
Header=''
bin=''
cc=''
contains=''
cpp=''
d_index=''
d_void=''
iandd=''
libc=''
mansrc=''
manext=''
n=''
c=''
package=''
registers=''
reg1=''
reg2=''
reg3=''
reg4=''
reg5=''
reg6=''
reg7=''
reg8=''
reg9=''
reg10=''
reg11=''
reg12=''
reg13=''
reg14=''
reg15=''
reg16=''
spitshell=''
shsharp=''
sharpbang=''
startsh=''
CONFIG=''
package=patch
echo "Beginning of configuration questions for $package kit."
: Eunice requires " " instead of "", can you believe it
echo " "
: sanity checks
PATH='.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/local:/usr/lbin:/etc'
export PATH || (echo "OOPS, this isn't sh. Desperation time. I will feed myself to sh."; sh $0; kill $$)
if test ! -t 0; then
echo "Say 'sh Configure', not 'sh <Configure'"
exit 1
fi
: some greps do not return status, grrr.
echo "grimblepritz" >grimble
if grep blurfldyick grimble >/dev/null 2>&1 ; then
contains=contains
else
if grep grimblepritz grimble >/dev/null 2>&1 ; then
contains=grep
else
contains=contains
fi
fi
rm -f grimble
: the following should work in any shell
case "$contains" in
contains*)
echo " "
echo "AGH! Grep doesn't return a status. Attempting remedial action."
cat >contains <<'EOSS'
grep "$1" "$2" >.greptmp && cat .greptmp && test -s .greptmp
EOSS
chmod 755 contains
esac
: first determine how to suppress newline on echo command
echo "Checking echo to see how to suppress newlines..."
(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
echo "...using -n."
n='-n'
c=''
else
echo "...using \\\c"
echo "c."
n=''
c='\c'
fi
echo $n "Type carriage return to continue. Your cursor should be here-->$c"
read ans
rm -f .echotmp
: now set up to do reads with possible shell escape
: if this does not work on your machine, 1,$ s/. myread/read ans/
cat <<EOSC >myread
ans='!'
while expr "X\$ans" : "X!" >/dev/null; do
read ans
case "\$ans" in
!)
sh
echo " "
echo $n "\$rp $c"
;;
!*)
set \`expr "X\$ans" : "X!\(.*\)\$"\`
sh -c "\$*"
echo " "
echo $n "\$rp $c"
;;
esac
done
rp='Your answer:'
EOSC
: general instructions
cat <<EOH
This installation shell script will examine your system and ask you questions
to determine how $package and any auxiliary files should be installed. If you
get stuck on a question, you may use a ! shell escape to start a subshell or
execute a command. Many of the questions will have default answers in
square brackets--typing carriage return will give you the default.
On some of the questions which ask for file or directory names you are
allowed to use the ~name construct to specify the login directory belonging
to "name", even if you don't have a shell which knows about that. Questions
where this is allowed will be marked "(~name ok)".
EOH
rp="[Type carriage return to continue]"
echo $n "$rp $c"
. myread
cat <<EOH
Much effort has been expended to ensure that this shell script will run
on any Unix system. If despite that it blows up on you, your best bet is
to edit Configure and run it again. (Trying to install this package
without having run Configure may be well nigh impossible.) Also, let me
(lwall@sdcrdcf.UUCP) know how I blew it.
This installation script affects things in two ways: 1) it may do direct
variable substitutions on some of the files included in this kit, and
2) it builds a config.h file for inclusion in C programs. You may edit
any of these files as the need arises after running this script.
EOH
rp="[Type carriage return to continue]"
echo $n "$rp $c"
. myread
: get old answers, if there is a config file out there
if test -f config.sh; then
echo " "
rp="I see a config.sh file. Did Configure make it on THIS system? [y]"
echo $n "$rp $c"
. myread
case "$ans" in
n*) echo "OK, I'll ignore it.";;
*) echo "Fetching default answers from your old config.sh file..."
. config.sh
;;
esac
fi
: get list of predefined functions in a handy place
echo " "
if test -f /lib/libc.a; then
echo "Your C library is in /lib/libc.a. You're normal."
libc=/lib/libc.a
else
if test -f /usr/lib/libc.a; then
echo "Your C library is in /usr/lib/libc.a, of all places."
libc=/usr/lib/libc.a
else
if test -f "$libc"; then
echo "Your C library is in $libc, like you said before."
else
cat <<'EOM'
I can't seem to find your C library. I've looked for /lib/libc.a and
/usr/lib/libc.a, but neither of those are there. What is the full name
EOM
echo $n "of your C library? $c"
rp='C library full name?'
. myread
libc="$ans"
fi
fi
fi
echo " "
echo $n "Extracting names from $libc for later perusal...$c"
if ar t $libc > libc.list; then
echo "done"
else
echo " "
echo "The archiver doesn't think $libc is a reasonable library."
exit 1
fi
: make some quick guesses about what we are up against
echo " "
echo $n "Hmm... $c"
if $contains SIGTSTP /usr/include/signal.h >/dev/null 2>&1 ; then
echo "Looks kind of like a BSD system, but we'll see..."
echo exit 0 >bsd
echo exit 1 >usg
echo exit 1 >v7
else
if $contains fcntl libc.list >/dev/null 2>&1 ; then
echo "Looks kind of like a USG system, but we'll see..."
echo exit 1 >bsd
echo exit 0 >usg
echo exit 1 >v7
else
echo "Looks kind of like a version 7 system, but we'll see..."
echo exit 1 >bsd
echo exit 1 >usg
echo exit 0 >v7
fi
fi
if $contains vmssystem libc.list >/dev/null 2>&1 ; then
cat <<'EOI'
There is, however, a strange, musty smell in the air that reminds me of
something...hmm...yes...I've got it...there's a VMS nearby, or I'm a Blit.
EOI
echo "exit 0" >eunice
eunicefix=unixtovms
d_eunice="$define"
: it so happens the Eunice I know will not run shell scripts in Unix format
else
echo " "
echo "Congratulations. You aren't running Eunice."
eunicefix=':'
d_eunice="$undef"
echo "exit 1" >eunice
fi
chmod 755 bsd usg v7 eunice
$eunicefix bsd usg v7 eunice
: see if sh knows # comments
echo " "
echo "Checking your sh to see if it knows about # comments..."
if sh -c '#' >/dev/null 2>&1 ; then
echo "Your sh handles # comments correctly."
shsharp=true
spitshell=cat
echo " "
echo "Okay, let's see if #! works on this system..."
echo "#!/bin/echo hi" > try
$eunicefix try
chmod 755 try
try > today
if test -s today; then
echo "It does."
sharpbang='#!'
else
echo "#! /bin/echo hi" > try
$eunicefix try
chmod 755 try
try > today
if test -s today; then
echo "It does."
sharpbang='#! '
else
echo "It doesn't."
sharpbang=': use '
fi
fi
else
echo "Your sh doesn't grok # comments--I will strip them later on."
shsharp=false
echo "exec grep -v '^#'" >spitshell
chmod 755 spitshell
$eunicefix spitshell
spitshell=`pwd`/spitshell
echo "I presume that if # doesn't work, #! won't work either!"
sharpbang=': use '
fi
: figure out how to guarantee sh startup
echo " "
echo "Checking out how to guarantee sh startup..."
startsh=$sharpbang'/bin/sh'
echo "Let's see if '$startsh' works..."
cat >try <<EOSS
$startsh
set abc
test "$?abc" != 1
EOSS
chmod 755 try
$eunicefix try
if try; then
echo "Yup, it does."
else
echo "Nope. You may have to fix up the shell scripts to make sure sh runs them."
fi
rm -f try today
: find out where common programs are
echo " "
echo "Locating common programs..."
pth="/usr/ucb /bin /usr/bin /usr/local /usr/local/bin /usr/lbin /etc /usr/lib"
cat <<EOSC >loc
$startsh
thing=\$1
shift
dflt=\$1
shift
for dir in \$*; do
case "\$thing" in
.)
if test -d \$dir/\$thing; then
echo \$dir
exit 0
fi
;;
*)
if test -f \$dir/\$thing; then
echo \$dir/\$thing
exit 0
fi
;;
esac
done
echo \$dflt
exit 1
EOSC
chmod 755 loc
$eunicefix loc
loclist="
expr
sed
echo
cat
rm
grep
"
trylist="
test
Mcc
"
for file in $loclist; do
xxx=`loc $file $file $pth`
eval $file=$xxx
case "$xxx" in
/*)
echo $file is in $xxx.
;;
*)
echo "I don't know where $file is. I hope it's in everyone's PATH."
;;
esac
done
echo " "
echo "Don't worry if any of the following aren't found..."
ans=offhand
for file in $trylist; do
xxx=`loc $file $file $pth`
eval $file=$xxx
case "$xxx" in
/*)
echo $file is in $xxx.
;;
*)
echo "I don't see $file out there, $ans."
ans=either
;;
esac
done
case "$egrep" in
egrep)
echo "Substituting grep for egrep."
egrep=$grep
;;
esac
case "$test" in
test)
echo "Hopefully test is built into your sh."
;;
/bin/test)
echo " "
echo $n 'Is your "test" built into sh? [n] (OK to guess) '"$c"
rp='test built into sh? [n]'
. myread
case "$ans" in
y*) test=test ;;
esac
;;
*)
test=test
;;
esac
case "$echo" in
echo)
echo "Hopefully echo is built into your sh."
;;
/bin/echo)
echo " "
echo "Checking compatibility between /bin/echo and builtin echo (if any)..."
$echo $n "hi there$c" >foo1
echo $n "hi there$c" >foo2
if cmp foo1 foo2 >/dev/null 2>&1; then
echo "They are compatible. In fact, they may be identical."
else
echo "They are not compatible--the echo builtin will be used."
echo=echo
fi
$rm -f foo1 foo2
;;
*)
echo=echo
;;
esac
: index or strcpy
$echo " "
if $contains index libc.list >/dev/null 2>&1 ; then
$echo "Your system appears to use index() and rindex() rather than strchr()"
$echo $n "and strrchr(). Is this correct? [y] $c"
rp='index() rather than strchr()? [y]'
. myread
case "$ans" in
n*|f*) d_index="$define" ;;
*) d_index="$undef" ;;
esac
else
$echo "Your system appears to use strchr() and strrchr() rather than index()"
$echo $n "and rindex(). Is this correct? [y] $c"
rp='strchr() rather than index()? [y]'
. myread
case "$ans" in
n*|f*) d_index="$undef" ;;
*) d_index="$define" ;;
esac
fi
: check for void type
$echo " "
$echo "Checking to see if your C compiler groks the void type..."
$cat >try.c <<'EOCP'
void main();
EOCP
if cc -c try.c >/dev/null 2>&1 ; then
d_void="$undef"
$echo "Yup, it does."
else
d_void="$define"
$echo "Nope, it doesn't (boo hiss). I will substitute int."
fi
$rm -f try.*
: see how we invoke the C preprocessor
echo " "
echo "Checking to see how your C preprocessor is invoked..."
cat <<'EOT' >testcpp.c
#define ABC abc
#define XYZ xyz
ABC.XYZ
EOT
echo 'Maybe "cc -E" will work...'
cc -E testcpp.c >testcpp.out 2>&1
if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
echo "Yup, it does."
cpp='cc -E'
else
echo 'Nope...maybe "cc -P" will work...'
cc -P testcpp.c >testcpp.out 2>&1
if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
echo "Yup, that does."
cpp='cc -P'
else
echo 'Nixed again...maybe "/lib/cpp" will work...'
/lib/cpp testcpp.c >testcpp.out 2>&1
if $contains 'abc.xyz' testcpp.out >/dev/null 2>&1 ; then
echo "Hooray, it works! I was beginning to wonder."
cpp='/lib/cpp'
else
echo 'Hmm...maybe you already told me...'
case "$cpp" in
'') ;;
*) $cpp testcpp.c >testcpp.ou component. */
X if (chdir(p) < 0 && mkdir(p, 0777) < 0 && chdir(p) < 0)
X Quit("Cannot chdir nor mkdir desired directory");
X }
X else
X cwd[0] = '\0';
X
X /* No buffering. */
X (void)setbuf(stdout, (char *)NULL);
X (void)setbuf(stderr, (char *)NULL);
X
X if (*av)
X /* Process filenames from command line. */
X for (; *av; av++) {
X if (cwd[0] && av[0][0] != '/') {
X (void)sprintf(buff, "%s/%s", cwd, *av);
X *av = buff;
X }
X if ((Stream = fopen(*av, "r")) == NULL)
X Fprintf(stderr, "unshar: Can't open file '%s'.\n", *av);
X else {
X Unshar(*av, HdrFile, Stream, Saveit, Forced);
X (void)fclose(Stream);
X }
X }
X else
X /* Do standard input. */
X Unshar((char *)NULL, HdrFile, stdin, Saveit, Forced);
X
X /* That's all she wrote. */
X exit(0);
X}
SHAR_EOF
if test 8368 -ne "`wc -c < 'unshar.c'`"
then
echo shar: error transmitting "'unshar.c'" '(should have been 8368 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'unshar.man'" '(2326 characters)'
if test -f 'unshar.man'
then
echo shar: will not over-write existing file "'unshar.man'"
else
sed 's/^X//' << \SHAR_EOF > 'unshar.man'
X.TH UNSHAR 1l
X.\" $Header: unshar.man,v 2.0 88/05/27 13:29:02 rsalz Exp $
X.SH NAME
Xunshar \- unpack shell archives from news, mail, notes, etc.
X.SH SYNOPSIS
X.B unshar
X[
X.BI \-c\| directory
X] [
X.BI \-d\| directory
X] [
X.BI \-h\| file
X] [
X.B \-f
X] [
X.B \-n
X] [
X.B \-s
X] [ file... ]
X.SH DESCRIPTION
X.I Unshar
Xremoves mail and news header lines from its input, and feeds the remainder
Xto
X.IR /bin/sh (1)
Xso that a shell archive can be properly unpacked.
XIf no files are specified,
X.I unshar
Xreads from standard input.
XThe program is designed to be useful when unpacking archives directly
Xfrom the news or mail systems (e.g., s | unshar).
X.PP
X.I Unshar
Xnormally unpacks its files in the current directory.
XUse the ``\-c'' option to have the program change to a new directory
Xbefore invoking the shell.
XIf the directory does not exist, it will try to create it.
XIf the directory name starts with a question mark, then
X.I unshar
Xwill ask for the directory name before doing anything; this is most useful
Xwith the environment variable UNSHAREDIR.
XIf the directory name starts with a tilde, then the value of the HOME
Xenvironment variable is inserted in place of that character.
XFor convenience, the ``\-d'' option is a synonym for the ``\-c'' option.
X.PP
X.I Unshar
Xnormally complains if the input looks like something other than a shar file.
X(Among other things, it checks for files that resemble C, and Pascal code).
XIt can be fooled, however, by nonstandard versions of news, notes, etc.
XThe ``\-f'' option forces
X.I unshar
Xto try unpacking files, even if they look like something else.
X.PP
XDepending on how the program is installed,
X.I unshar
Xmay or may not try to preserve the header part of file ``foo''
Xinto the name ``foo.hdr'' (if the file is standard input, the name
Xwill be ``UNSHAR.HDR'').
XUsing the ``\-s'' option forces the program to save the headers, while
Xusing the ``\-n'' option forces it to discard the headers.
XThe file is appended to, if it already exists, so all headers can be easily
Xsaved in one file.
XThe name of the file may be given by using the ``\-h'' option; this is
Xparticularly useful when processing more than one file at a time.
X.SH ENVIRONMENT
X.ta \w'UNSHAREDIR 'u
XHOME Value used if a leading tilde is given in directory name.
X.br
XUNSHAREDIR Default value for ``\-c'' option.
X.SH SEE ALSO
Xshar(1).
SHAR_EOF
if test 2326 -ne "`wc -c < 'unshar.man'`"
then
echo shar: error transmitting "'unshar.man'" '(should have been 2326 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
tr.t_lab, TEXT);
-}
-
-/*
- * Print out data.
- */
-
-void pdata(fid)
-register ef_fid fid;
-{
- register long dpos, endd;
- register int lng;
- unsigned ctyp;
- int had, par, inc;
- char *msg;
- d_entry dstr;
-
- (void) printf("\n.data\n");
-
- dpos = fid->ef_dbase;
- endd = dpos + fid->ef_dsize;